﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace iLangl.Plugin.ConfigFileSettings
{
	public class ConfigurationManager : IConfigurationManager
	{
		#region Singelton Pattern
		private ConfigurationManager()
		{
		}

		private static ConfigurationManager instance;
		private static object mutex = new object();
		/// <summary>
		/// The instance of the CompanyManager.
		/// </summary>
		public static ConfigurationManager Instance
		{
			get
			{
				if (instance == null)
				{
					lock (mutex)
					{
						if (instance == null)
						{
							instance = new ConfigurationManager();
						}
					}
				}
				return instance;
			}
		}
		#endregion

		#region IConfigurationManager Members

		public IPluginConfiguration GetPluginConfiguration()
		{
			return PluginConfiguration.Instance;
		}

		public void SavePluginConfiguration(IPluginConfiguration pluginConfiguration)
		{
			if (pluginConfiguration is PluginConfiguration)
			{
				(pluginConfiguration as PluginConfiguration).Save();
			}
			else
			{
				throw new NotSupportedException(String.Format("'{0}' is not supported by", pluginConfiguration.GetType(), this.GetType()));
			}
		}



		public IPluginConfiguration GetPluginConfiguration(string siteId)
		{
			return GetPluginConfiguration();
		}

	

		public string SiteId
		{
			get { return String.Empty; }
		}

		#endregion
	}
}
